<?php
include('../../__global.php');
class aj_getFeedComment extends ml_controller 
{
    private $_rid;
    private $oAccount;
    private $oComment;
    private $totalNum;
    public function initParam(){
        $this->_rid=$this->input('rid','g');
        $this->oAccount=new ml_model_dbUserAccount();
        $this->oComment=new ml_model_dbComment();    
    }
    public function checkParam(){
        $this->check_referer();
        if(!ml_tool_resid::is_resid($this->_rid))
            $this->api_output(ML_RCODE_PARAM);
            
        $this->oComment->getCountsByRid($this->_rid);
        $this->totalNum=$this->oComment->get_data();
        if($this->totalNum['num'] <= 4 )
            $this->api_output(ML_RCODE_PARAM);

    }
    
    
    public function main(){
        
        $oUserfeed=new ml_model_dbUserfeed();
        $rs=$this->oComment->getCommentsByRid($this->_rid,4,16);
        
        if(!$rs)
            $this->api_output(ML_RCODE_BUSY);
        
        $comments=$this->oComment->get_data();
        $htmlArr=ml_tool_commentOutput::parseCommentTpl($comments);
        
        $data['item']='';
        foreach ($htmlArr as $val){
            $data['item'].=$val;
        }
        $data['type']=1;
        $this->api_output(ML_RCODE_SUCC,$data);
    }
}
new aj_getFeedComment();